#pragma once

#include "AdoConnection.h"
#include "TableDataInfo.h"
#include <vector>
#include <map>



class STORAGEORDERPRODLLEXPORT CTableStorage
{
public:
	CTableStorage(void);
	~CTableStorage(void);
protected:
	CString m_createTable;
	CString m_checkTable;
	CString m_addColumne;
	CString m_checkColumne;
	CString m_createITrigger;
	CString m_checkITrigger;
	CString m_createUTrigger;
	CString m_checkUTrigger;
	CString m_createDTrigger;
	CString m_checkDTrigger;
	CString m_insertcolumn;
	std::vector<CTableDataInfo*>	m_TableData;
	int m_ColumnNum;
	int m_PrimaryNum;
protected:
	// SplitStr
	std::string m_SplitStr;
	CString		w_SplitStr;
public:
	std::map<int,CString>	m_ColumnData;
	std::map<int,CString>	m_PrimaryData;
	//CString Column_Data[];
protected:
	// CheckTable
	virtual bool CheckTable(CAdoConnection * pCN);
	// CheckColumne
	virtual bool CheckColumne(CAdoConnection * pCN);
	// CheckTrigger
	virtual bool CheckITrigger(CAdoConnection * pCN);
	// CheckTrigger
	virtual bool CheckUTrigger(CAdoConnection * pCN);
	// CheckTrigger
	virtual bool CheckDTrigger(CAdoConnection * pCN);
public:
	// CheckTableInfo
	virtual bool CheckTableInfo(CAdoConnection * pCN);
	// GetTableDataBySql
	virtual bool GetTableDataBySql(CAdoConnection * pCN,const CString& sql, 
		std::vector<CTableDataInfo *> & tabledata);
	virtual bool GetTableDataBySql(CAdoConnection * pCN,const CString& sql, 
		std::string &tabledata,std::string splitstr = "$#$");
	// ExecuteSql
	virtual bool ExecuteSql(CString tablename,CAdoConnection * pCN,const CString& sql);
	virtual bool GetValueDataByColumn(CTableDataInfo* data,  CString column,  CString& value);
	// GetTableSql
	virtual void GetTableSql(CString tablename,CString & sql);
	virtual void GetTableWhere(CString tablename,const CString & sqlwhere,CString & sql);
	virtual void SetTableWhere(CString tablename,const CString & sqlwhere,CString & sql);
	virtual bool ConvertRecvData(std::string &recvdata,std::vector<CTableDataInfo *> & tabledata);
protected:
public:
	// GetColumnNum
	int GetColumnNum(void);
	// GetPrimaryNum
	int GetPrimaryNum(void);
	// SetSplitStr
	void SetSplitStr(const char * split);
};

